import { _decorator, Component, EffectAsset, game, Material } from 'cc';
import { GLTF, Material as GMaterial } from './glTFParser';
const { ccclass, property, executionOrder } = _decorator;

@ccclass('glTFSettings')
@executionOrder(-1)
export class glTFSettings extends Component {
    private static _instance: glTFSettings = null!;
    static get instance(): glTFSettings {
        return glTFSettings._instance;
    }

    /**
     *  Called before creating material
     */
    static beforeCreateMaterial: (gltf: GLTF, matInfo: GMaterial) => Material = null!;

    /**
     * Called after creating material
     */
    static afterCrateMaterial: (gltf: GLTF, matInfo: GMaterial, material: Material) => Material = null!;


    @property(EffectAsset)
    unlitEffect: EffectAsset;

    protected onLoad(): void {
        game.addPersistRootNode(this.node);
        glTFSettings._instance = this;
    }
}